# -*- coding: utf-8 -*-

from marshmallow import Schema
from odoo_contrib.marshmallow import fields

from .fields import VideoUrl, Html


class ArticleSchema(Schema):
    id_ = fields.Integer(attribute='id', data_key='id')
    title = fields.Str()
    content = Html()
    view_count = fields.Integer(data_key='viewCount')
    image_url = fields.AttachmentUrl(attribute='image_id', data_key='imageUrl')
    video_url = VideoUrl(attribute='video', data_key='videoUrl',
                         model_xmlid='exhibition.article', filename_field='video_filename')


class ArticleRepositorySchema(Schema):
    entries = fields.List(fields.Nested(ArticleSchema))
    count = fields.Integer()
